<template>
    <el-card class="box-card">
        <div class="notice">
            <el-button style="float: right; padding: 5px 0" type="text" @click="noticeList">更多</el-button>
            <h1>公告栏</h1>
            <div @click="detail(notice.notice_id)" style="background-color: rgb(147, 194, 236);">
                <h2>{{ notice.title }}</h2>
                <p>
                    {{ notice.content }}
                </p>
            </div>
        </div>
    </el-card>
</template>
<script>
import axios from 'axios';

export default {

    data() {
        return {
            notice: []
        }
    },
    methods: {
        detail(id) {
            this.$router.push({ name: 'notice_detail', params: { notice_id: id } }, () => { }, () => { });
        },
        noticeList() {
            this.$router.push({ path: '/notice/list' }, () => { }, () => { });
        }
    },
    created: function () {
        let that = this;
        axios.get('http://127.0.0.1:5000/api/notice/get_obj', {
            params: {
                notice_id: 1
            }
        })
            .then(function (response) {
                console.log(response.data.result.obj);
                that.notice = response.data.result.obj;
            })
            .catch(function (error) {
                console.log(error);
            })
            .then(function () {
                // 总是会执行
            })
    }
}
</script>
<style scoped>
.text {
    font-size: 14px;
}

.item {
    padding: 18px 0;
}

.box-card {
    margin-left: 200px;
    margin-right: 200px;
    margin-top: 50px;
    margin-bottom: 50px;
    width: 1500px;
    height: 400px;

}
</style>